home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / TEXTATTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.6 KB  |  59 lines

  1. /* P892.C --- BIBLE */
  2. #include <conio.h>
  3. #define ESC '\033'
  4. char *fgnd[] = {"BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA", "BROWN",
  5.     "LIGHGRAY", "DARKGREY", "LIGHTBLUE", "LIGHTGREEN", "LIGHTCYAN",
  6.     "LIGHTRED", "LIGHTMAGENTA", "YELLOW", "WHITE"};
  7. char *bgnd[] = {"BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA",
  8.     "BROWN", "LIGHTGRAY"};
  9. char *blink[] = {"NOBLINK", "BLINK"};
  10. static int column = 0, row = 0, xypos[3][2] = {3, 4, 23, 4, 43, 4},
  11.     numattrs[3] = {16, 8, 2}, selection[3] = {7, 0, 0};
  12. static char **colorlist[3] = {fgnd, bgnd, blink};
  13. main()
  14. {
  15.     int i, j, c, attr;
  16.     window(10, 1, 70, 24);
  17.     clrscr();
  18.     textattr(LIGHTGRAY << 4 + BLACK);
  19.     gotoxy(10, 1);
  20.     cputs("Use Tab and Enter to move along columns");
  21.     gotoxy(20, 2);
  22.     cputs("Press ESC to exit");
  23.     textattr(LIGHTGRAY);
  24.     for(i = 0; i < 3; i++)
  25.     {
  26.         for(j = 0; j < numattrs[i]; j++)
  27.         {
  28.             gotoxy(xypos[i][0], xypos[i][1] + j);
  29.             cputs((colorlist[i])[j]);
  30.         }
  31.     }
  32.     while((c = getch()) != ESC)
  33.     {
  34.         textattr(WHITE + (BLACK << 4));
  35.         if(c == '\t')
  36.         {
  37.             column = (column + 1) % 3;
  38.         }
  39.         if(c == '\r')
  40.         {
  41.             gotoxy(xypos[column][0] - 1, xypos[column][1] +
  42.                             selection[column]);
  43.             putch(' ');
  44.             selection[column] = (selection[column] + 1)
  45.                                     % numattrs[column];
  46.         }
  47.         for(i = 0; i < 3; i++)
  48.         {
  49.             gotoxy(xypos[i][0] - 1, xypos[i][1] + selection[i]);
  50.             putch('*');
  51.         }
  52.         attr = (selection[1] << 4) + selection[0];
  53.         if(selection[2] != 0)
  54.             attr += BLINK;
  55.         textattr(attr);
  56.         gotoxy(1, 20);
  57.         cputs("This is how the current text attribute looks");
  58.     }
  59. }